<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  img {
    width: 300px;
    height: 400px;
  }
</style>

<body>
  <img id="myImage" src="./image/nature-1.jpg" alt="Your Image">
  <script>
    const image = document.getElementById('myImage');
    image.addEventListener('click', (e) => {
      // 获取鼠标点击的坐标
      const x1 = e.clientX;
      const y1 = e.clientY;
      // 获取图片的中心坐标
      const x2 = image.offsetLeft + image.offsetWidth / 2;
      const y2 = image.offsetTop + image.offsetHeight / 2;
      // 计算鼠标点击的坐标与图片中心的距离
      const distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
      // 计算鼠标点击的坐标与图片中心的角度
      let angle = Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI;
      angle = angle > 0 ? angle : 360 + angle
      console.log(angle);
      // 判断鼠标点击在第几象限
      if (angle >= 0 && angle < 90) {
        console.log('在第四象限');
      } else if (angle >= 90 && angle < 180) {
        console.log('在第一象限');
      } else if (angle >= 180 && angle < 270) {
        console.log('在第二象限');
      } else {
        console.log('在第三象限');
      }
    });
  </script>
</body>

</html>